package mini.expr.lists;
import java.util.List;
import java.util.LinkedList;

import mini.Env;
import mini.expr.Element;
import mini.expr.Expr;

public class ElementList extends Expr {
    private Sequence seq = null;

    public ElementList() {
        seq = new Sequence();
    }
    
    public ElementList(Sequence seq) {
        this.seq = seq;
    }
    
    public Sequence getSequence() {
        return seq;
    }
    
    @Override
    public Element eval(List<Env> listOfEnvs, LinkedList var) {
        seq.eval(listOfEnvs, var);
        
        return null;
    }
    
    public String toString() {
        StringBuilder toStringBuilder = new StringBuilder("[");
        
        for (Element element : seq.getElements()) {
            toStringBuilder.append(element).append(",");
        }
        
        if (toStringBuilder.length() > 1) {
            toStringBuilder.replace(toStringBuilder.length() - 1, toStringBuilder.length(), "]");
        } else {
            toStringBuilder.append("]");
        }
        
        return toStringBuilder.toString();
    }
    
    public ElementList clone() {
        ElementList newElementList = new ElementList();
        
        newElementList.seq = seq.clone();
        
        return newElementList;
    }
}
